String.prototype.format = function () {
    //将arguments转化为数组（ES5中并非严格的数组）
    var args = Array.prototype.slice.call(arguments);
    var count = 0;
    //通过正则替换%s
    return this.replace(/(%s|\?)/g, function (s, i) {
        return args[count++];
    });
}

String.prototype.isEmpty = function (obj) {
    try {
        if (obj == null || obj == undefined) {
            return true;
        }
        //判断数字是否是NaN
        if (typeof obj === "number") {
            if (isNaN(obj)) {
                return true;
            } else {
                return false;
            }
        }
        //判断参数是否是布尔、函数、日期、正则，是则返回false
        if (typeof obj === "boolean" || typeof obj === "function" || obj instanceof Date || obj instanceof RegExp) {
            return false;
        }
        //判断参数是否是字符串，去空，如果长度为0则返回true
        if (typeof obj === "string") {
            if (obj.trim().length == 0) {
                return true;
            } else {
                return false;
            }
        }

        if (typeof obj === 'object') {
            //判断参数是否是数组，数组为空则返回true
            if (obj instanceof Array) {
                if (obj.length == 0) {
                    return true;
                } else {
                    return false;
                }
            }

            //判断参数是否是对象，判断是否是空对象，是则返回true
            if (obj instanceof Object) {
                //判断对象属性个数
                if (Object.getOwnPropertyNames(obj).length == 0) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    } catch (e) {
        console.log(e);
        return false;
    }
}

String.prototype.getMidText = function (start, end) {
    if(''.isEmpty(start)) {
        return '';
    } 

    let startIndex = this.indexOf(start);
    if(startIndex == -1) {
        return '';
    }
    startIndex +=  start.length;

    if(''.isEmpty(end)){
      return this.substring(startIndex);
    }

    return this.substring(startIndex, this.indexOf(end, startIndex));
}
